package com.xiaochen.manager.service.impl;

import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaochen.manager.mapper.ProductSpecMapper;
import com.xiaochen.manager.service.ProductSpecService;
import com.xiaochen.model.entity.product.ProductSpec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 商品规格
 * @author pinkhors
 */
@Service
public class ProductSpecServiceImpl implements ProductSpecService {

    @Autowired
    private ProductSpecMapper productSpecMapper;

    /**
     * 分页条件查询
     */
    @Override
    public PageInfo<ProductSpec> selectByPage(ProductSpec productSpec, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProductSpec> list = productSpecMapper.selectByPage(productSpec);
        return new PageInfo<>(list);
    }

    /**
     * 添加
     */
    @Override
    public void saveProductSpec(ProductSpec productSpec) {
        productSpecMapper.saveProductSpec(productSpec);
    }

    /**
     * 删除
     */
    @Override
    public void deleteById(Long id) {
        productSpecMapper.deleteById(id);
    }

    /**
     * 修改
     */
    @Override
    public void updateProductSpec(ProductSpec productSpec) {
        productSpecMapper.updateProductSpec(productSpec);
    }

    /**
     * 查询出来所有的商品规格数据
     */
    @Override
    public List<ProductSpec> findAll() {
        return productSpecMapper.findAll();
    }
}
